package com.example.a22310.myapplication.ViewModel.Club;


import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.StaggeredGridLayoutManager;

import com.example.a22310.myapplication.Adapter.MvvmAdapter;
import com.example.a22310.myapplication.Listener.ClubListener;
import com.example.a22310.myapplication.Model.ClubModel;
import com.example.a22310.myapplication.R;

import java.util.List;

public class ClubVideoViewModel implements ClubListener<MediaStore.Video> {
    private FragmentClubVideoBinding binding;
    private FragmentActivity activity;



    public ClubVideoViewModel(FragmentActivity activity, int binding, FragmentClubVideoBinding club_id){
        this.activity = activity;
        this.binding = binding;
        binding.setModel(this);
        ClubModel clubModel=new ClubModel();
        clubModel.videolist(club_id,ClubVideoViewModel.this);
    }

    @Override
    public void onSuccess(MediaStore.Video video) {
        if(video.getCode()!=404){
            List<MediaStore.Video.ClubvideolistBean> clubvideolistBeen =  video.getClubvideolist();
            binding.recyclerViewClubVideo.setLayoutManager(new StaggeredGridLayoutManager(2,
                    StaggeredGridLayoutManager.VERTICAL));
            MvvmAdapter adapter = new MvvmAdapter(activity, R.layout.cardview_club_video,
                    clubvideolistBeen, BR.videos);
            binding.recyclerViewClubVideo.setAdapter(adapter);

        }

    }

    @Override
    public void onFailure() {
    }}
